package com.lemonfish.pojo.entity;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;

/**
 * User Entity定义
 *
 * @author Lemonfish
 * @version 1.0
 * @date 2020-03-01
 * Copyright © ï¿½Å³ï¿½
 */
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "User")
@Accessors(chain = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
public class User extends BaseCustomEntity {

    private static final long serialVersionUID = -8803658287829405L;

    // 帐号
    @ApiModelProperty(value = "帐号", required = true, example = "root")
    @NotNull(message = "帐号不能为空")
    @Length(max = 20, message = "帐号长度应小于20")
    @TableField()
    private String username;

    // 密码
    @ApiModelProperty(value = "密码", required = true, example = "123456")
    @NotNull(message = "密码不能为空")
    @Length(max = 20, message = "密码长度应小于20")
    @TableField()
    private String password;

    // 姓名
    @ApiModelProperty(value = "姓名", required = true, example = "张三")
    @NotNull(message = "姓名不能为空")
    @Length(max = 100, message = "姓名长度应小于100")
    @TableField()
    private String name;

    // 角色名
    @ApiModelProperty(value = "角色名", required = true, example = "超级管理员")
    @Length(max = 20, message = "角色名长度应小于20")
    @TableField()
    private String roleName;

    // 令牌
    @ApiModelProperty(value = "令牌", required = true, example = "00000")
    @Length(max = 200, message = "令牌长度应小于200")
    @TableField()
    private String token;

    // 更新时间
    @ApiModelProperty(value = "更新时间", required = true, example = "2020-03-02 19:54")
    @TableField(insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NOT_NULL)
    private Date updateTime;

    @TableField(exist = false)
    private List<Permission> permissions;

    // 手机号码
    @ApiModelProperty(value = "手机号码", required = true, example = "130")
    @NotNull(message = "手机号码不能为空")
    @Length(max = 20, message = "手机号码长度应小于20")
    @TableField()
    private String mobile;

    // 邮箱
    @ApiModelProperty(value = "邮箱", example = "")
    @Length(max = 100, message = "邮箱长度应小于100")
    @TableField()
    private String email;

    // 用户状态
    @ApiModelProperty(value = "用户状态", example = "true")
    @TableField()
    private Boolean userStatus;

    // 性别
    @ApiModelProperty(value = "性别", required = true, example = "true")
    @NotNull(message = "性别不能为空")
    @TableField()
    private Boolean sex;

    // 年龄
    @ApiModelProperty(value = "年龄", required = true, example = "18")
    @NotNull(message = "年龄不能为空")
    @TableField()
    private Integer age;
}
